<?php
App::uses('AppModel', 'Model');
/**
 * Image Model
 *
 * @property Item $Item
 */
class Image extends AppModel {
	
	/**
	 * Validation rules
	 *
	 * @var array
	 */
	public $validate = array(
			'item_id' => array(
					'numeric' => array(
							'rule' => array('numeric'),
							//'message' => 'Your custom message here',
							//'allowEmpty' => false,
							//'required' => false,
							//'last' => false, // Stop validation after this rule
							//'on' => 'create', // Limit validation to 'create' or 'update' operations
					),
			),
	);
	
	//The Associations below have been created with all possible keys, those that are not needed can be removed
	
/**
 * belongsTo associations
 *
 * @var array
 */
	public $belongsTo = array(
		'Item' => array(
			'className' => 'Item',
			'foreignKey' => 'item_id',
			'conditions' => '',
			'fields' => '',
			'order' => ''
		)
	);
	
	public function getItemById($imageId) {
		$image = $this->findById($imageId);
		$itemId = (!empty($image)) ? ($image['Image']['item_id']) : '';
		return $itemId;
	}
	public function getNameById($imageId) {
		$image = $this->findById($imageId);
		$imageName = (!empty($image)) ? ($image['Image']['name']) : '';
		return $imageName;
	}
	
	
	
}
